<?php 
require_once("../../config/config.inc.php");
require_once("../../classes/json.class.php");
$json = new Services_JSON();

$sAction = fn_getParam("strAction","menuList");
$sUpMenuCode = fn_getParam("strUpCode","0");
$sPreUrl = $CFG_WWWROOT."/apps/";

if ($sAction == 'menuList') {
    $aMenuList = array();
    $sql  = "SELECT MENUCODE,MENUNAME,URL,IMAGESRC,TIP,UPMENUCODE ";
    $sql .= "FROM $TABLE_SYSTEM_MENU WHERE UPMENUCODE='".$sUpMenuCode."' ";
    $sql .= "ORDER BY SHOWORDER";
    $stmt = $DB->query($sql);
    while ($row = $DB->fetchArray($stmt)) {
        $aMenuList[] = array('code'=>$row["MENUCODE"],'name'=>$row["MENUNAME"],'url'=>$sPreUrl.$row['URL'],
            'imagesrc'=>$CFG_WWWROOT."/".$row["IMAGESRC"],'tip'=>$row["TIP"],'upcode'=>$row["UPMENUCODE"]);
    }
    $DB->freeResult($stmt);

    //echo json_encode($nodes); //use in PHP5 version
    echo $json->encode(array('menus'=>$aMenuList));
}

?>
